<?php
// +----------------------------------------------------------------------
// | sfadmin - Suifeng Administration
// +----------------------------------------------------------------------
// | Copyright (c) 2017-2020 http://suifeng.tech All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: suifeng <1787585212@qq.com>
// +----------------------------------------------------------------------

namespace app\admin\helper;

final class Json
{
    /**
     * 编码数据为JSON格式。
     *
     * @param unknown $data
     * @return string
     */
    public function encode($data)
    {
        return json_encode($data, JSON_UNESCAPED_UNICODE);
    }

    /**
     * 解码JSON格式字符串。
     *
     * @param unknown $str
     * @return mixed
     */
    public function decode($str)
    {
        return json_decode($str, true);
    }
}